/*
 * AmpelThread.cpp
 *
 *  Created on: 12.04.2011
 *      Author: Jasper
 */

#include "AmpelThread.h"

void AmpelThread::execute(void * args)
{
    std::cout << "Started!" << std::endl;

    HWaccess::init();

    while(!isStopped())
    {
        int ports[] = {AMPEL_ROT, AMPEL_GELB, AMPEL_GRUN};
        int rot[] = {1, 0, 0};
        int gelb[] = {0, 1, 0};
        int grun[] = {0, 0, 1};

        std::cout << "rot" << std::endl;
        HWaccess::setV(ports, rot, 3);
        sleep(1);

        if(isStopped())
            break;

        std::cout << "gelb" << std::endl;
        HWaccess::setV(ports, gelb, 3);
        sleep(1);

        if(isStopped())
            break;

        std::cout << "gruen" << std::endl;
        HWaccess::setV(ports, grun, 3);
        sleep(1);
    }
}

void AmpelThread::shutdown()
{
    std::cout << "Cleaning up!" << std::endl;
}

AmpelThread::AmpelThread()
{
}

AmpelThread::~AmpelThread()
{
}
